<?php

/**
 * @Author:      西北民大杨志宏
 * @DateTime:    2015-12-14 19:38:18
 * @Description: 知识点模型
 */

/**
 * 用户管理模型
 */
class KnowledgePoint_model extends CI_Model {

	/**
	 * [add 添加用户注册信息]
	 *
	 * @param [array] $data [用户注册信息，包括用户名、密码和注册时间]
	 */
	public function add( $data ) {
		$this->db->insert( 'knowledgepoint' , $data );
	}

	/**
	 * 取得所有数据
	 */
	public function getAllData()
	{
		return $this->db->get('knowledgepoint')->result_array();
	}

	/**
	 * 取得单个数据
	 */
	public function getLastCotent()
	{
		$sql = 'SELECT * FROM knowledgepoint ORDER BY errorNumber DESC, learningtime ASC, displayNumber ASC';
		return $this->db->query($sql)->first_row('array');
	}

	// 更新学习次数
	public function updateDisplayTime($kid, $displayNumber)
	{
		$data = array('displayNumber' => $displayNumber);
		$this->db->where(array('kid' => $kid))->update('knowledgepoint', $data );
	}

}
?>
